package org.oslims.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.google.gwt.validation.client.NotEmpty;
import com.google.gwt.validation.client.NotNull;

@Entity
public class AnalysisResult extends AbstractBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 957460353043419532L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@ManyToOne
	@JoinColumn(name = "SAMPLE_FK")
	@NotNull
	private AbstractSample sample;

	@ManyToOne
	@JoinColumn(name = "ANALYSIS_FK")
	@NotNull
	private Analysis analysis;

	@ManyToOne
	@JoinColumn(name = "LABSTAFF_FK")
	@NotNull
	private LabStaff assignedBy;

	@Temporal(TemporalType.TIMESTAMP)
	@NotNull
	private Date assignedAt;

	@Temporal(TemporalType.TIMESTAMP)
	private Date deadline;

	@Temporal(TemporalType.TIMESTAMP)
	private Date startAt;

	@Temporal(TemporalType.TIMESTAMP)
	private Date completedAt;

	@NotEmpty
	private String state;

	@OneToMany(mappedBy = "analysisResult")
	@NotNull
	private List<ParameterResult> parameterResults = new ArrayList<ParameterResult>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public AbstractSample getSample() {
		return sample;
	}

	public void setSample(AbstractSample sample) {
		this.sample = sample;
	}

	public Analysis getAnalysis() {
		return analysis;
	}

	public void setAnalysis(Analysis analysis) {
		this.analysis = analysis;
	}

	public LabStaff getAssignedBy() {
		return assignedBy;
	}

	public void setAssignedBy(LabStaff assignedBy) {
		this.assignedBy = assignedBy;
	}

	public Date getAssignedAt() {
		return assignedAt;
	}

	public void setAssignedAt(Date assignedAt) {
		this.assignedAt = assignedAt;
	}

	public Date getDeadline() {
		return deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}

	public Date getStartAt() {
		return startAt;
	}

	public void setStartAt(Date startAt) {
		this.startAt = startAt;
	}

	public Date getCompletedAt() {
		return completedAt;
	}

	public void setCompletedAt(Date completedAt) {
		this.completedAt = completedAt;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public List<ParameterResult> getParameterResults() {
		return parameterResults;
	}

	public void setParameterResults(List<ParameterResult> parameterResults) {
		this.parameterResults = parameterResults;
	}

}
